package cn.edu.nuaa.aadl2.AdaGenerator.templateAda

import org.osate.aadl2.impl.SubprogramSubcomponentImpl
import org.osate.aadl2.SubprogramImplementation
import org.osate.aadl2.SubprogramType
import static extension cn.edu.nuaa.aadl2.AdaGenerator.templateAda.SubprogramImplementationTemplateAda.*
import static extension cn.edu.nuaa.aadl2.AdaGenerator.templateAda.SubprogramTypeTemplateAda.*
import static extension cn.edu.nuaa.aadl2.AdaGenerator.utils.StringUtils.*
import org.osate.aadl2.SubprogramSubcomponent
import cn.edu.nuaa.aadl2.AdaGenerator.utils.Tools
import org.osate.aadl2.ComponentClassifier

class SubprogramTemplateAda {
	
	def static genSystemSubprogramSubcomponent(String parentFolder, SubprogramSubcomponent sub, String systemName){
			TemplateAda.addLogMessage("函数",sub.name)
			Tools.folder2(parentFolder)
			Tools.createFile(parentFolder, 
				systemName.convert+"-"+sub.name.convert+".adb", 
				sub.classifier.template4Adb.toString)
			Tools.createFile(parentFolder, 
				systemName.convert+"-"+sub.name.convert+".ads", 
				sub.classifier.template4Ads.toString)
	}
	
	def static template4Adb(ComponentClassifier sub ){
		switch sub{
			SubprogramImplementation:
			{	
				println("SubprogramImplementation")
				return sub.templateAdb
			}
			
			SubprogramType:
			{	
				println("SubprogramType")
				return sub.templateAdb
			}
			default:
				return sub.class.toString
		}
	}
	def static template4Ads(ComponentClassifier sub ){
		switch sub{
			SubprogramImplementation:
			{	
				println("SubprogramImplementation")
				return sub.templateAds
			}
			
			SubprogramType:
			{	
				println("SubprogramType")
				return sub.templateAds
			}
				default:
				return sub.class.toString
		}
	}	
}